package com.qd.p2p.web.action.borrow;

import org.apache.struts2.convention.annotation.Action;

import com.opensymphony.xwork2.ModelDriven;
import com.qdlc.p2p.biz.web.action.BaseAction;
import com.qdlc.p2p.dal.dto.BorrowBespeak;

/**
 * 预约借款
 * @author sj
 * @since 2014-8-20
 *
 */
public class BorrowBespeakAction  extends BaseAction<BorrowBespeak> implements ModelDriven<BorrowBespeak> {

	private BorrowBespeak borrowBespeak = new BorrowBespeak();
	
	@Override
	public BorrowBespeak getModel() {
		return borrowBespeak;
	}
	
	/**
	 * 预约借款页面
	 * @return
	 * @throws Exception
	 */
	@Action(value = "/borrowBespeak/bespeak")
	public String bespeak() throws Exception {
		return "bespeak";
	}
	
	/**
	 * 预约借款操作
	 * @return
	 * @throws Exception
	 *//*
	@Action(value = "/borrowBespeak/doBespeak",interceptorRefs = {@InterceptorRef("session"), 
			@InterceptorRef("globalStack") })
	public void doBespeak() throws Exception {
		User user = userService.getUserById(getSessionUserId());
		UserCache userCache = user.getUserCache();
		if (user.getTppStatus() != 1) {
			data.put("result", false);
			data.put("msg", "请先在第三方开户！");
		}
		if(borrowBespeak.getCompanyName() == null){
			data.put("result", false);
			data.put("msg", "公司名称不能为空！");
		}else if(borrowBespeak.getName() == null){
			data.put("result", false);
			data.put("msg", "联系人不能为空！");
		}else if(borrowBespeak.getTelephone() == null){
			data.put("result", false);
			data.put("msg", "手机号码不能为空！");
		}else{
			data.put("result", true);
			data.put("msg", "预约借款申请成功！");
		}
		
		// 保存数据
		borrowBespeak = borrowBespeakService.doBespeak(borrowBespeak);
		
		// 封装小贷提交数据
		BorrowBespeakModel bespeakModel = new BorrowBespeakModel(user.getUserName(), 
				user.getRealName(), user.getMobilePhone(), user.getCardId(), userCache.getSex(), 
				borrowBespeak.getMoney(), borrowBespeak.getLimitTime(), borrowBespeak.getBorrowUse(), borrowBespeak.getRemark());
		EloanLog eloanLog = new EloanLog(bespeakModel.getOrderId(), 0, JSON.toJSONString(bespeakModel));
		eloanLogService.save(eloanLog);
		HessianProxyFactory factory = new HessianProxyFactory();
		String url = ("http://localhost/baseService");
		P2PRemotelyTransferService transferService =  (P2PRemotelyTransferService) factory.create(P2PRemotelyTransferService.class, url);
		transferService.addCreditIntent(JSON.toJSONString(bespeakModel));
		printWebJson(getStringOfJpaObj(data));
	}
	*/
}
